package com.wsestadio.util;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DAOConexionUtil {

	private static final Logger log = LoggerFactory.getLogger(DAO.class);

//	public static EntityManagerFactory getEntityManagerFactory() {
//		try {
//			int context = getPropiedadInt("persistence.jndi.conextion");
//			EntityManagerFactory emf = null;
//			if (context == Constantes.INICIAR_JDNI_CONTEXT) {
//				log.info("getEntityManagerFactory INICIAR_JDNI_CONTEXT");
//				emf = entityManagerFactoryContext();
//			} else if (context == Constantes.INICIAR_TEST) {
//				log.info("getEntityManagerFactory INICIAR_TEST");
//				emf = entityManagerFactory();
//			}
//			log.info("EntityManagerFactory:" + emf.getProperties());
//			return emf;
//		} catch (Exception e) {
//			log.error(e);
//			e.printStackTrace();
//		}
//		return null;		
//	}
//
//	public static EntityManagerFactory entityManagerFactory() {
//		EntityManagerFactory emf = null;
//		String puName = getPropiedad("persistence.name");
//		String driver = getPropiedad("javax.persistence.jdbc.driver");
//		String url = getPropiedad("javax.persistence.jdbc.url");
//		String user = getPropiedad("javax.persistence.jdbc.user");
//		String password = getPropiedad("javax.persistence.jdbc.password");
//		log.info("entityManagerFactory puName:" + puName);
//		log.info("entityManagerFactory driver:" + driver);
//		log.info("entityManagerFactory url:" + url);
//		log.info("entityManagerFactory user:" + user);
//		Map<String, Object> properties = new HashMap<String, Object>();
//		properties.put("javax.persistence.jdbc.driver", driver);
//		properties.put("javax.persistence.jdbc.url", url);
//		properties.put("javax.persistence.jdbc.user", user);
//		properties.put("javax.persistence.jdbc.password", password);
//		properties.put("persistenceXmlLocations", "/META-INF/db_contabilidad.xml");		
//		emf = Persistence.createEntityManagerFactory(puName, properties);
//		return emf;
//	}
//
//	public static EntityManagerFactory entityManagerFactoryContext() {
//		String puName = getPropiedad("persistence.name");
//		log.info("entityManagerFactoryContext puName:" + puName);
//		return Persistence.createEntityManagerFactory(puName);
//	}

}
